package main

import "fmt"

// 方法的组合
type report struct {
	sol        int
	teperature teperature
	location   location
}

// 匿名的嵌套
type reportDemo struct {
	sol int
	teperature
	location
}

type teperature struct {
	high, low celsius
}

type celsius float64

func (t teperature) average() celsius {
	return (t.high + t.low) / 2
}

type location struct {
	lat, long float64
	sol       int
}

func main() {
	bradbury := location{lat: -12.323, long: 1.4342}

	t := teperature{high: 2, low: 4}

	reprot := report{
		sol:        15,
		teperature: t,
		location:   bradbury,
	}

	fmt.Printf("%+v \n", reprot)

	// 转发
	fmt.Printf("average=%v \n", reprot.teperature.average())

	reportDemo := reportDemo{
		sol:        15,
		teperature: t,
		location:   bradbury,
	}

	fmt.Printf("%+v \n", reportDemo)

	// 转发
	fmt.Printf("average=%v \n", reportDemo.average())
	// 转发
	fmt.Printf("average=%v \n", reportDemo.teperature.average())
	fmt.Printf("average=%v \n", reportDemo.sol)
}
